package com.team.sion.mapper;

import com.team.sion.pojo.Consumer;
import com.team.sion.pojo.ConsumerExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface ConsumerMapper {
    long countByExample(ConsumerExample example);

    int deleteByExample(ConsumerExample example);

    @Delete({
        "delete from consumer",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into consumer (id, username, ",
        "password, sex, phone_num, ",
        "email, birth, introduction, ",
        "location, avator, ",
        "createTime, updateTime, ",
        "old_password)",
        "values (#{id,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, ",
        "#{password,jdbcType=VARCHAR}, #{sex,jdbcType=VARCHAR}, #{phone_num,jdbcType=VARCHAR}, ",
        "#{email,jdbcType=VARCHAR}, #{birth,jdbcType=DATE}, #{introduction,jdbcType=VARCHAR}, ",
        "#{location,jdbcType=VARCHAR}, #{avator,jdbcType=VARCHAR}, ",
        "#{createtime,jdbcType=DATE}, #{updatetime,jdbcType=DATE}, ",
        "#{old_password,jdbcType=VARCHAR})"
    })
    int insert(Consumer row);

    int insertSelective(Consumer row);

    List<Consumer> selectByExample(ConsumerExample example);

    @Select({
        "select",
        "id, username, password, sex, phone_num, email, birth, introduction, location, ",
        "avator, createTime, updateTime, old_password",
        "from consumer",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("com.team.sion.mapper.ConsumerMapper.BaseResultMap")
    Consumer selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("row") Consumer row, @Param("example") ConsumerExample example);

    int updateByExample(@Param("row") Consumer row, @Param("example") ConsumerExample example);

    int updateByPrimaryKeySelective(Consumer row);

    @Update({
        "update consumer",
        "set username = #{username,jdbcType=VARCHAR},",
          "password = #{password,jdbcType=VARCHAR},",
          "sex = #{sex,jdbcType=VARCHAR},",
          "phone_num = #{phone_num,jdbcType=VARCHAR},",
          "email = #{email,jdbcType=VARCHAR},",
          "birth = #{birth,jdbcType=DATE},",
          "introduction = #{introduction,jdbcType=VARCHAR},",
          "location = #{location,jdbcType=VARCHAR},",
          "avator = #{avator,jdbcType=VARCHAR},",
          "createTime = #{createtime,jdbcType=DATE},",
          "updateTime = #{updatetime,jdbcType=DATE},",
          "old_password = #{old_password,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Consumer row);
}